import { Toast } from 'vant'
// import router from '@/router/index'
export default {
  namespaced: true,
  state: {
    telList: JSON.parse(localStorage.getItem('phoneNum')) || [],
  },
  mutations: {
    addInList(state, payload) {
      if (state.telList.some((item) => item === payload.phone)) {
        Toast.fail({
          message: '该号码已被注册',
        })
      } else {
        state.telList.push(payload.phone)
        Toast.success({
          message: '注册成功！',
        })
        payload.a.push('/home')
        // router.push('/home')
      }
    },
  },
  actions: {
    addInListAsync(context, payload) {
      setTimeout(() => {
        context.commit('addInList', payload)
      }, 1000)
    },
  },
}
